//
//  EYTouchController.h
//  touch
//
//  Created by easy on 11-5-25.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
@class EYTouch;
@protocol EYTouchDelegate;

@interface EYTouchController : NSObject {
	NSMutableArray /*EYTouch*/*touches;
	id<EYTouchDelegate> delegate;
}


@property (nonatomic,retain) id<EYTouchDelegate> delegate;	//触摸委托
@property (readonly) int touchCount;						//当前touch 数
@property (nonatomic,readonly) NSMutableArray /*EYTouch*/*touches;		//touch管理数组

-(EYTouch *) touchAtIndex:(NSUInteger) index;
//是否存在该触摸
-(BOOL) exists : (UITouch *)touch;
//触摸点对应的EYTouch
-(EYTouch *) touchFor : (UITouch *)touch;

//新的touch点开始时，将未管理的touch加入到管理数组
-(void) touchesBegan:(NSSet *)_touches event:(UIEvent *)event;
//结束touch时，将结束的touch从管理数组移除
-(void) touchesEnded:(NSSet *)_touches event:(UIEvent *)event;
//移动的时候对touch处理
-(void) touchesMoved:(NSSet *)_touches event:(UIEvent *)event;
//放弃touch点时，将其移除
-(void) touchesCancelled:(NSSet *)_touches event:(UIEvent *)event;



@end

@interface EYTouch : NSObject{
	UITouch *touch;
	CGPoint start;
}
//开始触摸点
@property (readonly) CGPoint start;
//包装的UITouch
@property (nonatomic,readonly) UITouch *touch;
//当前的点击相对touch所在view的值
@property (readonly) CGPoint current;
//当前偏移量
@property (readonly) CGPoint offset;
//根据UITouch初始化
-(id) initWithTouch:(UITouch *) _touch;
//重定义开始点为当前点
-(void) restart;

//当前touch到指定touch的缩放值
-(float) scaleTo:(EYTouch *) _touch;
//当前touch到指定touch的角度
-(float) rotateTo:(EYTouch *) _touch;
//当前touch到指定touch的位移
-(CGPoint) translateTo:(EYTouch *) _touch;
@end
 
@protocol EYTouchDelegate
@optional
//这里touches 为变动的EYTouch
-(void) didTouchBegan:(NSArray /*EYTouch*/*) touches event:(UIEvent *)event controller:(EYTouchController *)controller;
-(void) didTouchEnded:(NSArray /*EYTouch*/*) touches event:(UIEvent *)event controller:(EYTouchController *)controller;
-(void) didTouchMoved:(NSArray /*EYTouch*/*) touches event:(UIEvent *)event controller:(EYTouchController *)controller;
-(void) didTouchCancelled:(NSArray /*EYTouch*/*) touches event:(UIEvent *)event controller:(EYTouchController *)controller;
@end